﻿#ifndef FINGERPRINTENROLL_H
#define FINGERPRINTENROLL_H

/**
 *
 */


#include <QObject>
#include <QByteArray>
#include <QImage>

namespace ZKFP
{

class FingerprintReader;
class FingerprintCacheDB;

/**
 * @brief The FingerprintEnroll class 辅助类，用于将同一手指的三次采集到的指纹模板合成一个指纹模板
 *                                    这样合成后的指纹模板包含指纹信息更全面，判别准确率更高。
 *                                    其实这个过程不应该叫 enroll， enroll 应该包括将结果注册到数据库中。
 *                                    但是没想好更好的词，所以暂时就叫这个词吧。
 */
class FingerprintEnroll : public QObject
{
    Q_OBJECT
public:
    explicit FingerprintEnroll(FingerprintCacheDB *cacheDB = nullptr, QObject *parent = nullptr);
    void setFingerprintCacheDB(FingerprintCacheDB *cacheDB);
    QByteArray regTemplate() const {return m_regTemplate;}
signals:
    void enrollFinished(QByteArray regTemplate);
    void enrollFailed();
    void fingerprintRejected();
    void fingerprintAccepted();
public slots:
    void reset();
    bool addFPTemplate(QByteArray fpTemplate);
    bool addFingerprint(QImage fingerImage, QByteArray fpTemplate);
    void beginEnroll(ZKFP::FingerprintReader * reader);
    void cancelEnroll();
private:
    FingerprintReader * m_reader;
    FingerprintCacheDB *m_cacheDB;
    QByteArray m_fpTemplate[3];
    QByteArray m_regTemplate;
    bool m_bRegister;
    int m_enrollIdx;
};

}
#endif // FINGERPRINTENROLL_H
